<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');

class Report extends CI_Controller {
	function index($url){
		$this->load->model('site_model');
		$site_list = $this->site_model->get_site_url_news();
		$url = isset($url)?$url :'media';
		$site = $this->site_model->get_site_one(array('url'=>$url));
	
		//接收参数
		$per_page 			= $this->input->get('per_page')?$this->input->get('per_page'):0;
		$txt = trim($this->input->get('txt'));
		$data = array();
		$data['where']['nid'] = $site['id'];
		$data['where']['txt'] = $txt;
		$data['page_size']  = ARTICLE_LIST_PAGE_SIZE;
		$data['page_start'] = (int)$per_page;
		$data['select'] 	= 1;
		$this->load->model('article_model');
		$vdata = $this->article_model->get_article_list($data);
		$vdata['site_list'] =$site_list;
		//分页
		$this->load->library('pagination');
		$config['base_url'] = "/article/index/$url.html?txt=".$txt;
		$config['total_rows'] = $vdata['article_count'];
		$config['per_page'] = ARTICLE_LIST_PAGE_SIZE; 
		$this->pagination->initialize($config); 
		
		$vdata['title'] 	= $site['title'].CON_WEBNAME;
		$vdata['keywords'] 	= $site['keywords'];
		$vdata['description'] 	= $site['description'];
		
		$vdata['nid'] 		= $nid;
		$vdata['site'] 		= $site;
		$vdata['url'] = $url;
		$vdata['txt'] = $txt;
		$vdata['atype']='report';
		$this->load->view('site/report', $vdata);
		
	}
	
	function view($article_id){
		$this->load->model('site_model');
		$site_list = $this->site_model->get_site_url_news();
		
		$this->load->model('article_model');
  		$article = $this->article_model->get_article_obj($article_id);
  		
  		$vdata['site'] = $this->site_model->get_site_obj($article['nid']);
  		
  		$vdata['article'] = $article;
  		$vdata['site_list'] =$site_list;
  		$vdata['title']   = $article['title'].' - '.CON_WEBNAME;
  		$vdata['keywords'] 	= $article['keywords'];
		$vdata['description'] 	= $article['summary'];
		
  		$vdata['atype']='report';
  		
  		$this->load->view("site/report_detail", $vdata);
	}
}